genVectorCrossProdLen
in genMath.lib
Vector Functions Function List by Category Alphabetical Function List
int genVectorCrossProdLen(
float *VectorA,
// pointer to vector A array
float *VectorB,
// pointer to vector B array
int dimen,
// dimension of A and B
float *CrossProdLen) // pointer to
store result
This function computes the length of the Vector Cross Product of two vectors of dimension n:
Length of Cross Product = sqrt{ (A dot A)(B dot B) + (A dot B)^2 }
The
return code is errno, defined in the C standard library (math.h). This is
an integer value
for math errors.
Sample Application:
/////////// splgCPL.c for genVectorCrossProdLen Library Function /////
// // //
// For this sample, 3-d vectors are used. Vectors are stored //
// in arrays a and b, and the cross product length is returned //
// into a scalar, c. //
// //
//////////////////////////////////////////////////////////////////////
//////////////////////////// INCLUDES ////////////////////////////////
#include "stdio.h"
#include "genMath.h"
////////////////////////////// MAIN //////////////////////////////////
void main()
{
//local declarations
//integers
int retcode; // return code for call to genVectorCrossProdLen
//floats
float a[3]; // vector A
float b[3]; // vector B
float c; // result
//character strings
char ch; // input string to exit
//intialize the A and B vectors
a[0] = (float)1.234;
a[1] = (float)-.678;
a[2] = (float)10.3;
b[0] = (float)4.559;
b[1] = (float)3.24;
b[2] = (float)0.3422;
//compute the dot product
retcode = genVectorDotProd(a,b,3,&c);
//display the result
printf("%s%f%s", "Length of the cross product vector = ", c,"\n\n");
//display closing message and wait for <enter> before exiting
printf("Press <Enter> to end");
scanf("%c", &ch);
} // End Main
/////////////////////////////// End splgCPL.c ///////////////////////